package com.ruoyi.logistic.controller;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.logistic.domain.*;
import com.ruoyi.logistic.domain.vo.NetworkCMCollectVo;
import com.ruoyi.logistic.service.NetworkCustomerManageCollectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequestMapping("/network/customerManageCollect")
@RestController
@Api(tags = "网点财务_客户经营_汇总")
public class NetworkCustomerManageCollectController {
    @Autowired
    private NetworkCustomerManageCollectService networkCustomerManageCollectService;

    @ApiOperation("单量_客户详情")
    @PostMapping("/singleCustomer")
    public R CMSingleCustomerCollect(NetworkCMCollectVo vo){
        List<NetworkCMSingleCustomerCollect> cmSingleCustomerCollects = networkCustomerManageCollectService.CMSingleCustomerCollect(vo);
        if (cmSingleCustomerCollects == null || cmSingleCustomerCollects.size() == 0){
            return R.fail("暂无数据");
        }else {
            return R.ok(PageInfo.info(cmSingleCustomerCollects));
        }
    }

    @ApiOperation("单量_单量趋势(近7天)")
    @PostMapping("/singleTrendByDay")
    public R singleTrendByDay(NetworkCMCollectVo vo){
        return R.ok(networkCustomerManageCollectService.singleTrendByDay(vo));
    }

    @ApiOperation("单量_单量趋势(近6个月)")
    @PostMapping("/singleTrendByMonth")
    public R singleTrendByMonth(NetworkCMCollectVo vo){
        return R.ok(networkCustomerManageCollectService.singleTrendByMonth(vo));
    }

    @ApiOperation("单量_指标概览")
    @PostMapping("/collectSingleIndex")
    public R collectSingleIndex(NetworkCMCollectVo vo){
        return R.ok(networkCustomerManageCollectService.collectSingleIndex(vo));
    }

    @ApiOperation("成本_客户详情")
    @PostMapping("/costCustomer")
    public R CostCustomerCollect(NetworkCMCollectVo vo){
        List<NetworkCMCostCustomerCollect> cmCostCustomerCollects = networkCustomerManageCollectService.CostCustomerCollect(vo);
        if (cmCostCustomerCollects == null || cmCostCustomerCollects.size() == 0){
            return R.fail("暂无数据");
        }else {
            return R.ok(PageInfo.info(cmCostCustomerCollects));
        }
    }
    @ApiOperation("成本_成本趋势(近7天)")
    @PostMapping("/costTrendByDay")
    public R costTrendByDay(NetworkCMCollectVo vo){
        return R.ok(networkCustomerManageCollectService.CMCostTrendByDay(vo));
    }

    @ApiOperation("成本_成本趋势(近6个月)")
    @PostMapping("/costTrendByMonth")
    public R costTrendByMonth(NetworkCMCollectVo vo){
        return R.ok(networkCustomerManageCollectService.CMCostTrendByMonth(vo));
    }

    @ApiOperation("成本_指标概览")
    @PostMapping("/collectCostIndex")
    public R collectCostIndex(NetworkCMCollectVo vo){
        return R.ok(networkCustomerManageCollectService.CMCostIndex(vo));
    }

    @ApiOperation("货品_客户详情")
    @PostMapping("/productCustomerCollect")
    public R productCustomerCollect(NetworkCMCollectVo vo){
        List<NetworkCMProductCustomerCollect> cmProductCustomerCollects = networkCustomerManageCollectService.productCustomerCollect(vo);
        if (cmProductCustomerCollects == null || cmProductCustomerCollects.size() == 0){
            return R.fail("暂无数据");
        }else {
            return R.ok(PageInfo.info(cmProductCustomerCollects));
        }
    }
}
